PBCatMoveSync
PBCatMove Transfer file or directory to another directory
#include <Files.h> File Manager (PBxxx)
OSErr PBCatMove(pb, async ); CMovePBPtr pb ; address of a 52-byte CMovePBRec structure Boolean async ; 0=await completion; 1=immediate return PBCatMove relocates the directory entry of a file or directory into a
different directory on the same disk. File contents are not transferred; this is
strictly a directory-modification operation. If a file ID exists for the file being
moved, the file ID remains with the file.
pb is the address of a 52-byte CMovePBRec structure. The relevant fields are as follows:
Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE) -> ioNamePtr StringPtr 4 18 Address of source full or partial filename -> ioVRefNum short 2 22 Volume, drive, or working directory
-> ioNewName StringPtr 4 28 Address of destination directory name -> ioNewDirID long 4 36 'Hard' ID of destination dir (0=use name/vref)
-> ioDirID long 4 48 'Hard' ID of source directory (0=use ioNewName)
<- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet) async is a Boolean value. Use FALSE for normal (synchronous) operation or TRUE to enqueue the request and resume control immediately. See Async I/O.
noErr (0) No error
badMovErr (-122) Can't move into offspring
bdNamErr (-37) Bad file name or attempt to move into file
dupFNErr (-48) Duplicate filename (destination file/dir already exists)
fnfErr (-43) Source file not found
ioErr (-36) I/O error
nsvErr (-35) No such volume
paramErr (-50) No default volume
vLckdErr (-46) Volume is locked
wPrErr (-44) Diskette is write-protected
Notes: The file or directory specified by ioNamePtr, ioVRefNum, and ioDirID (in
various combinations), is transferred to the directory identified by
ioNewName and/or ioNewDirID.
Note: If ioNewName is given, it must be a directory name (never a filename, even when moving a file).
PBCatMove cannot transfer between different disks ( volumes) nor can it
rename an item - use PBHRename for that. This function is smart enough
to prevent you from moving a directory into a file or into an offspring
directory.
As with PBHxxx functions, you may use 0 in ioDirID if you specify the
full pathname (of the source file) in ioNamePtr. If you specify the full
pathname in ioNewName, you can use ioNewDirID = 0.
Example
#include <Files.h>
/* === move file using fully-qualified path names === */
cmpb.ioNamePtr = (StringPtr)"\pHardDisk:Ltrs:Current:Smith";
cmpb.ioNewName = (StringPtr)"\pHardDisk:Ltrs:Old"; // last : optional
cmpb.ioDirID = cmpb.ioNewDirID = 0; // not needed since
cmpb.ioVRefNum = 0; // using a full name
rc = PBCatMove( &cmpb, FALSE ); if ( rc ) { /* . . . handle the error . . . */ }
/* === move a whole directory into the root === */
cmpb.ioNamePtr = (StringPtr)"\pHardDisk:Ltrs:"; // last : optional
cmpb.ioDirID = 0; // not needed; ioNamePtr
cmpb.ioVRefNum = 0; // has the volume and dir
cmpb.ioNewName = 0; Í// not needed; ioNewDirID given
cmpb.ioNewDirID = 2; // 'Hard' ID of root directory
rc = PBCatMove( &cmpb, FALSE ); if ( rc ) { /* . . . handle the error . . . */ }